/*
Package employee
@Time : 2022/12/20 21:22
@Author : 董胜烨
@File : main
@Software: GoLand
@note:
*/
package main

import (
	"employee/model"
	setting "employee/pkg"
	"employee/routers"
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func init() {
	setting.Setup()
	model.Setup()
}

func main() {
	gin.SetMode(setting.AppSetting.RunMode)
	routersInit := routers.InitRouter()
	server := &http.Server{
		Addr:         fmt.Sprintf(":%d", setting.ServerSetting.HttpPort),
		Handler:      routersInit,
		ReadTimeout:  setting.ServerSetting.ReadTimeout,
		WriteTimeout: setting.ServerSetting.WriteTimeout,
	}
	log.Printf("[info] start http server listening %d\n", setting.ServerSetting.HttpPort)

	err := server.ListenAndServe()
	if err != nil {
		log.Fatalln("main listenAndServer error,", err)
		return
	}
}
